using UnityEngine;

public class MonsterEnable : MonoBehaviour
{
    private MonsterSpawner monsterSpawner;

    void Awake()
    {
        // 获取 MonsterSpawner 组件
        monsterSpawner = GetComponent<MonsterSpawner>();
        // 初始时禁用 MonsterSpawner 脚本
        monsterSpawner.enabled = false;
    }

    void OnTriggerEnter2D(Collider2D other)
    {
        // 检查碰撞对象是否为玩家
        if (other.CompareTag("Player"))
        {
            // 启用 MonsterSpawner 脚本
            monsterSpawner.enabled = true;
        }
    }
}